//
//  ESTVerticalValueView.m
//  ESTSCRMAPP
//
//  Created by 李贤立 on 2018/9/28.
//  Copyright © 2018年 Capfer. All rights reserved.
//

#import "ESTVerticalValueView.h"

@interface ESTVerticalValueView ()
@property (weak, nonatomic) IBOutlet UILabel *valueLabel;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;

@end

@implementation ESTVerticalValueView

+ (instancetype)valueViewWithName:(NSString *)name value:(NSString *)value {
    return [self valueViewWithName:name value:value backgroundColorModel:BackgroundColor_White];
}
+ (instancetype)valueViewWithName:(NSString *)name value:(NSString *)value backgroundColorModel:(ESTVerticalValueViewBackgroundColor)backgroundColorModel {
    return [self valueViewWithName:name value:value backgroundColorModel:backgroundColorModel nameFontSize:Activity_Home_Text_FontSize];
}
+ (instancetype)valueViewWithName:(NSString *)name value:(NSString *)value backgroundColorModel:(ESTVerticalValueViewBackgroundColor)backgroundColorModel nameFontSize:(CGFloat)nameFontSize {
    ESTVerticalValueView *view = [[NSBundle mainBundle] loadNibNamed:@"ESTVerticalValueView" owner:nil options:nil].lastObject;
    view.nameLabel.text = name;
    view.valueLabel.text = value;
    if (name && !value) {
        view.valueLabel.text = @"0";
    }
    view.nameLabel.font = [UIFont systemFontOfSize:nameFontSize];
    view.valueLabel.font = [UIFont systemFontOfSize:nameFontSize + 12];
    switch (backgroundColorModel) {
        case BackgroundColor_White:
            view.nameLabel.textColor = TYZWhiteColor;
            view.valueLabel.textColor = TYZWhiteColor;
            break;
        case BackgroundColor_Black:
            view.nameLabel.textColor = TYZBlackColor;
            view.valueLabel.textColor = TYZBlackColor;
            break;
        case BackgroundColor_Gray:
            view.nameLabel.textColor = TYZLightMColor;
            view.valueLabel.textColor = TYZBlackColor;
            view.nameLabel.font = [UIFont systemFontOfSize:nameFontSize - 2];
            view.valueLabel.font = [UIFont systemFontOfSize:nameFontSize + 10];
            break;
        default:
            view.nameLabel.textColor = ThemeColor;
            view.valueLabel.textColor = ThemeColor;
            break;
    }
    return view;
}
- (IBAction)didClickCoverButton:(UIButton *)sender {
    if (self.didClickCoverBlock) {
        self.didClickCoverBlock();
    }
}
@end
